﻿@model PagedList.IPagedList<OMS.Models.UserModelView>

@{
    ViewBag.Title = "Filter";
}

<h2>All users</h2><br />
@Html.ActionLink("New user", "AddUser")<br />
Total:  @ViewBag.UserCount users
    
<table align=center>
    <tr>
        <th>User Name</th>
        <th>First name</th>
        <th>Last Name</th>
        <th>Role</th>
        <th>Email</th>
        <th>Region</th>
        <th>Edit</th>
        <th>Remove</th>
        <th>Duplicate</th>
    </tr>

@foreach (var user in Model)
{
        <tr>
            <td>
                @Html.DisplayFor(i => user.Login)
            </td>
            <td>
                @Html.DisplayFor(i => user.FirstName)
            </td>
            <td>
                @Html.DisplayFor(i => user.LastName)
            </td>
            <td>
                @Html.DisplayFor(i => user.Role)
            </td>
            <td>
                @Html.DisplayFor(i => user.Email)
            </td>
            <td>
                @Html.DisplayFor(i => user.Region)
            </td>
            <td>
                @Html.ActionLink("Edit", "EditUser", new { id = user.Id })
            </td>
            <td>
                @Html.ActionLink("Remove[WIP]", "DeleteUser", new { id = user.Id })
            </td>
            <td>
                @Html.ActionLink("Duplicate[WIP]", "Duplicate", new { id = user.Id })
            </td>
            <td>        
            </td>
        </tr>
}
</table>
<div align=center>
    Page @(Model. PageCount < Model.PageNumber ? 0 : Model.PageNumber)
    of @Model.PageCount
     
    @if (Model.HasPreviousPage)
    {
        @Html.ActionLink("First", "GetAllUsers", new { page = 1 })
        @Html.Raw(" ");
        @Html.ActionLink("< Prev", "GetAllUsers", new { page = Model.PageNumber - 1 })
    }
    else
    {
        @:First
        @Html.Raw(" ");
        @:< Prev
    }
     
    @if (Model.HasNextPage)
    {
        @Html.ActionLink("Next >", "GetAllUsers", new { page = Model.PageNumber + 1 })
        @Html.Raw(" ");
        @Html.ActionLink("Last", "GetAllUsers", new { page = Model.PageCount })
    }
    else
    {
        @:Next >
        @Html.Raw(" ")
        @:Last
    }
</div>